# Test3client.py
import socket
from DesModule import des_encrypt, des_decrypt

tcpclient = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpclient.connect(("192.168.10.51", 2028))
KEY = "12345678"  # 保证KEY长度为8

while True:
    data = input('>>> ').strip()
    if data == "exit":
        break
    encrypted_data = des_encrypt(data, KEY)
    tcpclient.send(encrypted_data.encode('utf-8'))
    ret = tcpclient.recv(1024)
    decrypted_response = des_decrypt(ret.decode('utf-8'), KEY)
    print("Server replied:", decrypted_response)

tcpclient.close()